package com.boot.rocketmq.consumer;


import com.boot.rocketmq.message.DemoTopicMessage;
import lombok.SneakyThrows;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(
        topic = DemoTopicMessage.TOPIC,
        consumerGroup = "demo01-A-consumer-group-" + DemoTopicMessage.TOPIC
        //,messageModel = MessageModel.BROADCASTING
)
public class Demo01AConsumer implements RocketMQListener<MessageExt> {


    private Logger logger = LoggerFactory.getLogger(getClass());

    @SneakyThrows
    @Override
    public void onMessage(MessageExt message) {
        logger.info("集群消息Demo01AConsumer A-原始 消费了一条消息");
        logger.info("集群消息Demo1 A-原始 [onMessage][线程编号:{} 消息内容：{}]", Thread.currentThread().getId(),
                new String(message.getBody(),"UTF-8"));
    }

}
